<%@ page language="java" pageEncoding="utf8"%>
<jsp:include page="/head_admin.jsp" />
<script type="text/javascript" src="script/movie.js"></script>
<script type="text/javascript">
	dojo.require("dijit.Dialog");
    dojo.require("dijit.form.SimpleTextarea");
    dojo.require("dijit.form.DateTextBox");
    
    function hideUploadWindow() {
    	dijit.byId("uploadImgDlg").hide();
    };
	function showUploadWindow(){
		dijit.byId("uploadImgDlg").show();
	};
	function showNewMovieTypeWindow(){
		dijit.byId("addMovieTypeDlg").show();
	};
	function hideMovieTypeWindow() {
		dijit.byId("addMovieTypeDlg").hide();
	};
	
	var mtName;
	function addMovieType(){
		mtName = document.getElementById("movieTypeName").value;
		var href = "addMovieType.do?mtName="+mtName;
		ajaxRequest(href, updateMtStore, null);
	};
	function updateMtStore () {
		var item = {
			name:mtName
		};
		
		movieTypeStore.newItem(item);
		document.getElementById("movieTypeName").value = "";
		hideMovieTypeWindow();
	};
	
	var movieTypeName = {
	   	items:[]
    };
   
    var movieTypeStore = new dojo.data.ItemFileWriteStore({
    	data:movieTypeName
    });
</script>
<script type="text/javascript">
   	dojo.addOnLoad(function(){
   		Movie.askForMovieType();
   	});
</script>

<div class="maincontent">
	<div class="HackBox"></div>
	<div id="breadcrumb">
		&nbsp;
		<a href="index.jsp">主页</a>&nbsp;&gt;&nbsp;
		<a href="movieManage.jsp">电影管理</a>&nbsp;&gt;&nbsp;添加电影
	</div>

	<div class="maincontentin">
		<div class="addBook_div">
			<span class="addBook_bar"> <span class="left"></span> <span
				class="addMovie_icon">&nbsp;添加电影&nbsp;</span>(带星号的为必填内容) </span>
			<form id="addMovieForm" name="addMovieForm" action="addMovie.do" method="post" >
				<table class="addBookTable">
					<tr>
						<td width="30%">
							<span class="addBookTitle">电影海报</span>
						</td>
						<td>
							<span class="addBookTitle" style="margin-left: 50px;">基本信息：</span>
						</td>
					</tr>
					<tr>
						<td width="30%">
							<div class="upLoadImg">
								<img src="images/bookImages/no_pic.gif" id="imgUrl">
								</img>
								<input type="hidden" id="image" name="image"/>
							</div>
							<div style="padding: 10px 0 0 0;">
								<span class="blue-btn"><a href="#"
									onclick="showUploadWindow();"><span class="l"></span>上传图片</a> </span>
							</div>
						</td>
						<td>
							<table class="basicInfo">
								<tr>
									<td class="label"><span style="color:red">*</span>电影名： 
									</td>
									<td>
										<input dojoType="dijit.form.ValidationTextBox" id="newMovieName"
											name='newMovieName' required="true" invalidMessage="请输入电影名" />
									</td>
									<td> 
										输入电影的全称 
									</td>
								</tr>
								<tr>
									<td class="label"><span style="color:red">*</span>语言： 
									</td>
									<td>
										<input dojoType="dijit.form.ValidationTextBox"
											id="language" name='language' required="true"
											invalidMessage="请输入影片语言" />
									</td>
									<td>输入影片的语言 
									</td>
								</tr>
								<tr>
									<td class="label"><span style="color:red">*</span>时长： 
									</td>
									<td>
										<input dojoType="dijit.form.ValidationTextBox" id="time"
											name='time' required="true" invalidMessage="请输入影片的时长" />
									</td>
									<td> 
										输入影片的时长 
									</td>
								</tr>
								<tr>
									<td class="label"><span style="color:red">*</span>上映日期： 
									</td>
									<td>
										<input type="text" name="shownTime" id="shownTime"
											dojoType="dijit.form.DateTextBox"
											constraints="{datePattern:'yyyy-MM-dd'}" required="true"
											invalidMessage="请输入上映日期" />
									</td>
									<td>
										格式(2008-01-12)
									</td>
								</tr>
								<tr>
									<td class="label">
										<span style="color:red">*</span>地区：
									</td>
									<td>
										<select id="zoneContainer" name="zoneContainer"
											style="width: 220px" dojoType="dijit.form.ComboBox">
											<option value="Name" selected="selected">大陆</option>
                                            <option value="Owner">欧美</option>
                                            <option value="Owner">港台</option>
										</select>
									</td>
									<td>
										选择影片所属地区
									</td>
								</tr>
								<tr>
									<td class="label">
										<span style="color:red">*</span>影片类型：
									</td>
									<td>
										<select id="movieTypeContainer" name="movieTypeContainer"
											style="width: 220px" dojoType="dijit.form.ComboBox" store="movieTypeStore">
										</select>
									</td>
									<td>
										<span class="orange-btn"> <span class="inputbtn">
												<span class="l"></span> <input type="button"
													onclick="showNewMovieTypeWindow();" value='添加类别'></input> </span> </span>
									</td>
								</tr>
							</table>
						</td>
					</tr>
					<tr>
						<td colspan="2">
							<hr class="dotline"></hr>
						</td>
					</tr>
					<tr>
						<td colspan="2">
							<table class="onboardInfo">
								<tr>
									<td class="label"><span style="color:red">*</span>导演： 
									</td>
									<td>
										<input dojoType="dijit.form.ValidationTextBox"
											id="directorsName" name='directorsName' required="true"
											invalidMessage="请输入导演，多个导演请以逗号（，）隔开" />
									</td>
									<td class="label">主演： 
									</td>
									<td>
										<input dojoType="dijit.form.ValidationTextBox" id="actors"
											name='actors' required="false" invalidMessage="请输入主演，多个主演请以逗号（，）隔开" />
									</td>
								</tr>
								<tr>
									<td class="label">摄影：  
									</td>
									<td>
										<input dojoType="dijit.form.ValidationTextBox"
											id="photographers" name='photographers' required="false"
											invalidMessage="请输入摄影，多个摄影请以逗号（，）隔开" />
									</td>
									<td class="label">编剧：
									</td>
									<td>
										<input dojoType="dijit.form.ValidationTextBox"
											id="screenwriters" name="screenwriters" required="false"
											invalidMessage="请输入编剧，多个编剧请以逗号（，）隔开" />
									</td>
								</tr>
								<tr>
									<td colspan="4">
										<div class="addBookTitle">
											<span style="color:red">*</span>剧情介绍
										</div>
										<div style="margin: 10px; width: 90%;">
											<textarea id="description" name="description"
												dojoType="dijit.form.SimpleTextarea" rows=4
												style="width: 100%;"></textarea>
										</div>
									</td>
								</tr>
							</table>
						</td>
					</tr>
					<tr>
						<td colspan="2">
							<div class="buttonbar">
								<div class="btngroup">
									<span class="blue-btn"> <span class="inputbtn"> <span
											class="l"></span> <input type="submit" value='保存'></input> </span> </span>
									<span class="blue-btn"> <span class="inputbtn"> <span
											class="l"></span> <input type="submit" value='保存继续添加'></input>
									</span> </span>
									<span class="blue-btn"> <span class="inputbtn"> <span
											class="l"></span> <input type="reset" value='重新填写' onclick="reset();"></input> </span> </span>
								</div>
							</div>
						</td>
					</tr>
				</table>
			</form>

		</div>


	</div>
	<!--  action="uploadimage.jsp" target="_blank" -->
	<div id="uploadImgDlg"
		style="display: none; width: 40%; height: 100px;"
		dojoType="dijit.Dialog" title='上传图片' class="pop-window">
		<table border="0" align="center" cellpadding="0" cellspacing="0">
			<tr>
				<td height="45" align="center" valign="middle">
					<form method="post" target="_blank" action="uploadimage.jsp"
						enctype="multipart/form-data" name="form1">
						选择要上传的图片
						<input type="file" name="file" id="file">
						<input type="submit" name="Submit" value="上传">
					</form>
				</td>
			</tr>
		</table>
	</div>

	<div id="addMovieTypeDlg"
		style="display: none; width: 40%; height: 100px;"
		dojoType="dijit.Dialog" title='添加类别' class="pop-window">
		<form action="" method="post">
		<label>
			输入需要添加的类别名称：
		</label>
		<input dojoType="dijit.form.ValidationTextBox" id="movieTypeName"
			name='movieTypeName' required="true" invalidMessage="请输入新的类别" />
		<button dojoType="dijit.form.Button" onclick="addMovieType();">
			确认
		</button>
		</form>
	</div>
</div>

<!-- main content -->


<jsp:include page="footer.jsp" />